package com.adgox.tiantianbiting.adapter;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.adgox.tiantianbiting.R;
import com.adgox.tiantianbiting.bean.TradeRecordBean;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by tang on 2019/3/1.
 */

public class TingCoinRecordAdapter extends RecyclerView.Adapter<TingCoinRecordAdapter.ViewHolder> {

    private List<TradeRecordBean> datas;

    public TingCoinRecordAdapter(List<TradeRecordBean> datas) {
        this.datas = datas;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_bonus_record, parent, false);
        ViewHolder holder = new ViewHolder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        TradeRecordBean bean = datas.get(position);
        holder.tvAmount.setText(bean.getBalance()+"听币");
        holder.tvTime.setText(bean.getCreateTimeStr());
        switch (bean.getPayStatus()){
            case 4:
                holder.tvType.setText("助力");
                break;
            case 5:
                holder.tvType.setText("听时长");
                break;
            case 6:
                holder.tvType.setText("随机活动");
                break;
            case 7:
                holder.tvType.setText("邀请好友");
                break;
            case 8:
                holder.tvType.setText("唤醒好友");
                break;
            case 9:
                holder.tvType.setText("提现拒绝");
                break;

        }
    }

    @Override
    public int getItemCount() {
        return datas.size();
    }

    class ViewHolder extends RecyclerView.ViewHolder{
        @BindView(R.id.tv_type)
        TextView tvType;
        @BindView(R.id.tv_time)
        TextView tvTime;
        @BindView(R.id.tv_amount)
        TextView tvAmount;

        ViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }
    }
}
